//
//  BDMNetworkManager.h
//  iJobs
//
//  Created by Li Xiaopeng on 15/1/22.
//  Copyright (c) 2015年 liyingpeng. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BDMHTTPRequestModel.h"
#import "BDMError.h"
#import "BDMUploadFileModel.h"
#import "BDMDownloadFileModel.h"

/*!
 @class
 @abstract BDM网络控制器
 */
@interface BDMNetworkManager : NSObject

/*!
 @method
 @abstract 网络控制器单例
 @discussion
 
 
 @result
 */
+ (BDMNetworkManager *)sharedInstance;

/*!
 @method
 @abstract 初始化缓存大小
 @discussion
 @result
 */
- (void)urlCacheInitialization;

/*!
 @method
 @abstract 清除所有url缓存
 @discussion
 @result
 */
- (void)clearAllURLCache;

/*!
 @method
 @abstract 发送Http请求
 @discussion
 @param aRequestModel 请求数据model
 @param aSuccessBlock 成功block
 @param　aFailureBlock　失败block
 @result
 */
-(void)sendHttpRequestWithModel:(BDMHTTPRequestModel *) aRequestModel
                        success:(void (^)(id responseObject))aSuccessBlock
                        failure:(void (^)(BDMError *error))aFailureBlock;

/*!
 @method
 @abstract 批量发送Http请求
 @discussion
 @param modelArray 请求数据model数组
 @param progress 每个请求执行的回调
 @param complete 所有请求执行完后的回调
 @param　isResultRestrict　结果是否严格限制（yes表示每有一个请求失败立刻执行complete，
 no 表示单个的请求失败并不影响整体的回调，依然会等最后一个回调执行后再执行complete）
 @result
 */
- (void)sendHttpRequestGroupWithModelArray:(NSArray<BDMHTTPRequestModel *> *)modelArray
                                  progress:(void(^)(id responseObject, NSString *identifier, BDMError *error))progress
                                  complete:(void(^)(BOOL isRequestSuccess))complete
                          isResultRestrict:(BOOL)isResultRestrict;

/**
 *  @brief  上传文件时调用方法
 *
 *  @param aUploadFileModel 上传数据的model
 *  @param aProgressBlock   上传进度block
 *  @param aSuccessBlock    成功block
 *  @param aFailureBlock    失败block
 */
- (void)uploadFileWithFileModel:(BDMUploadFileModel *)aUploadFileModel
              progressCallBack:(void (^)(NSUInteger __unused bytesWritten,
                                         long long totalBytesWritten,
                                         long long totalBytesExpectedToWrite))progressBlock
                       success:(void (^)(id responseObject))aSuccessBlock
                       failure:(void (^)(NSError *error))aFailureBlock;

/**
 *  @brief  下载文件时调用方法
 *
 *  @param aDownloadModel 下载数据的model
 *  @param progressBlock  下载进度block
 *  @param aSuccessBlock  成功block
 *  @param aFailureBlock  失败block
 */
- (void)downloadFileWithFileModel:(BDMDownloadFileModel *)aDownloadModel
                 progressCallBack:(void (^)(NSUInteger bytesRead,
                                            long long totalBytesRead,
                                            long long totalBytesExpectedToRead))progressBlock
                          success:(void (^)(id responseObject))aSuccessBlock
                          failure:(void (^)(NSError *error))aFailureBlock;

/*!
 @method
 @abstract 取消一个特定id的请求
 @discussion
 @param aIdentifier 请求ID
 @result
 */
- (void)cancelRequestForIdentifier:(NSString *)aIdentifier;

/*!
 @method
 @abstract 取消一组特定id的请求
 @discussion
 @param requestIDList IDList
 @result
 */
- (void)cancelRequestForIdentifierList:(NSMutableArray *)requestIDList;

/*!
 @method
 @abstract 取消所有请求
 @discussion
 @result
 */
- (void)cancelAllRequest;

/**
 *  @brief  发送心跳，保持登录连接
 
 */
- (void)startSendHeartbeat;

/**
 *  @brief  停止发送心跳
 
 */
- (void)stopSendHeartbeat;

@end
